import 'package:flutter/material.dart';

/// This widget presents as a button with [icon] on the top and the [label] on the bottom.
///
/// This widget actually built on [TextButton].
/// [textColor] is the color for the text in the button. The default is [Colors.black].
/// [icon] will shown on the top. [label] will be shown on the bottom. [onPressed] is a [VoidCallback].
class IconButtonWithBottomLabel extends StatelessWidget {
  const IconButtonWithBottomLabel({
    super.key,
    this.textColor,
    required this.icon,
    required this.label,
    this.onPressed,
  });

  final Widget icon;
  final Widget label;
  final Color? textColor;
  final VoidCallback? onPressed;

  @override
  Widget build(BuildContext context) {
    return TextButton(
      onPressed: onPressed,
      style: ButtonStyle(
        foregroundColor:
            WidgetStateProperty.all<Color>(textColor ?? Colors.black54),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          icon,
          label,
        ],
      ),
    );
  }
}
